package main

import (
	"github.com/sirupsen/logrus"
	"time"
)

const FormatTimeLayout = "2006-01-02 15:04"

func main() {
	splitByTime()
	splitByLevel()
}

func splitByTime() {
	InitFileDateHook("./src/03_gin/12_log/logrus/3_log_split/logs", "testApp")
	logrus.Errorln(time.Now().Format(time.TimeOnly), "异常1")
	logrus.Errorln(time.Now().Format(time.TimeOnly), "异常2")
	logrus.Errorln(time.Now().Format(time.TimeOnly), "异常3")
	logrus.Warnln(time.Now().Format(time.TimeOnly), "警告1")
	logrus.Warnln(time.Now().Format(time.TimeOnly), "警告2")
}

func splitByLevel() {
	InitFileLevelHook("./src/03_gin/12_log/logrus/3_log_split/logs", "testApp")
	logrus.Errorln(time.Now().Format(time.TimeOnly), "异常1")
	logrus.Errorln(time.Now().Format(time.TimeOnly), "异常2")
	logrus.Errorln(time.Now().Format(time.TimeOnly), "异常3")
	logrus.Warnln(time.Now().Format(time.TimeOnly), "警告1")
	logrus.Warnln(time.Now().Format(time.TimeOnly), "警告2")
	logrus.Infoln(time.Now().Format(time.TimeOnly), "正常1")
	logrus.Infoln(time.Now().Format(time.TimeOnly), "正常2")
}
